package com.seata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seata.mapper.OrderMapper;
import com.seata.model.Order;
import com.seata.service.OrderService;
import io.seata.core.context.RootContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: TongRui乀
 * @Date: 2019-12-05 17:11
 * @description：
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Integer createOrder(Order order) {

        System.err.println("全局事务ID：" + RootContext.getXID());

        try {

            this.orderMapper.insert(order);
        }catch (Exception e){
            e.printStackTrace();
            return 500;
        }

        return 200;
    }
}
